﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>职务管理</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var $grid;
        var maiheight = 500;
        var $selectRow = null;
        var height = 0;
        var has_select = false;
        var tree = null;

        $(function () {
            maiheight = $(window).height();

            $("#layout1").ligerLayout({ leftWidth: 170, heightDiff: -0 });
            height = $(".l-layout-center").height();

            //显示gride
            $grid = $("#maingrid").ligerGrid({
                columns: [
               { display: '序号', align: 'left', width: 40, type: 'int', isSort: false,
                   render: function (item, i) {
                       i = i + 1;
                       return i;
                   }
               },
                { display: '职务名称', name: 'R_NAME', align: 'left', width: 80 },
                { display: '备注', name: 'R_REMARK', width: 200 },
                { display: '创建日期', name: 'R_DATE', dateFormat: "yyyy-MM-dd", width: 80 },
                { display: '区域', name: 'A_NAME', width: 130 },

                  { display: '职务权限', name: 'R_POWER', isSort: false, width: 60,
                      render: function (item) {
                          if (item.R_POWER == 0) return "普通员工";
                          else if (item.R_POWER == 1) return "管理员";
                          else
                              return "";
                      }
                  },
                  { display: '状态', name: 'J_STATUS', isSort: false, width: 80,
                      render: function (item) {
                          if (item.J_STATUS == "True") return "√";
                          else return "×";
                      }
                  },
                  { display: '停/启用', name: 'J_ID', isSort: false, width: 60,
                      render: function (item) {
                          if (item.J_STATUS == "False")
                              return "<a   onclick='StopItem(" + item.J_ID + ", 1 )' href='javascript:' >启用</a>";
                          else
                              return "<a   onclick='StopItem(" + item.J_ID + ", 0 )' href='javascript:' >停用</a>";
                      }
                  }


                ],
                  parms: [
                            { name: 'roleName', value: $("#roleName").val() },
                            { name: 'aid', value: '-1' },
                            { name: 'status', value: $("#lstStatus").val() }
                        ],
                dataAction: 'server', pageSize: 20,
                url: '../WebServer/RoleMange.ashx?Action=AreaRoleList',
                sortName: 'R_NAME',
                width: '100%', height: '95%'
            });
            $("#treePanel").height(height - 24);

            loadTree();
        });

        function loadTree() {
            tree = $("#Orgtree").ligerTree({
                checkbox: false,
                slide: false,
                nodeWidth: 100,
                url: '../WebServer/MainAdmin.ashx?Action=AreaTree&rnd=' + Math.random(),
                onSelect: function (node) {
                        has_select = true;
                        $("#Aid").val(node.data.id);
                        $("#lstStatus").val("-1");
                        $("#roleName").val("");
                        $("#hdAreaName").val(node.data.text);
                        loadGrid();
                }
            });
        }

        function Search() {
            var node = tree.getSelected();
            if (node == null) {
                $("#Aid").val("-1");
                $("#hdAreaName").val("");
            }
            loadGrid();
        }

        function loadGrid() {
            if (!$grid) return;
            $("tbody > tr", $grid.gridbody).each(function () {
                $(this).remove();
            });

            $grid.setOptions({ parms: [
                                { name: 'roleName', value: $("#roleName").val() },
                                { name: 'aid', value: $("#Aid").val() },
                                { name: 'status', value: $("#lstStatus").val() }
                               ],newPage: 1, Rows: [], Total: 0 
            });   //设置数据参数

            $grid.loadData(true); //加载数据
            closeDialog();
        }

        function AddRole() {
            ShowDialog("sysManage/AddRole.htm", "添加职务", 600, 400);
        }

        function FenRole() {
            var are = -1;
            var node = tree.getSelected();
            if (node != null) {
                are = parseInt(node.data.id);
            }

            if (are == -1) {
                showErrorTip("请选定区域后再分配职务.");
                return;
            }
            ShowDialog("sysManage/FenAreRole.htm", "分配职务", 600, 520);
        }

        function StopItem(id , status) {
            $("body").mask("数据处理中，请稍候......");

            $.getJSON('../WebServer/RoleMange.ashx?Action=stopItem', { jid: id, stas: status }, function (data) {
                $("body").unmask();
                if (data.IsSuccess == 1) {
                    showAlertOk("操作成功.");
                    loadGrid();
                } else {
                    showErrorTip(data.Msg);
                }
            });  //end ajax
        }

        function ExportExecl() {
            var url = "../WebServer/DownloadExcel.ashx?Action=AreRoleList"
                  + "&roleName=" + $("#roleName").val()
                  + "&aid=" + $("#Aid").val()
                  + "&status=" + $("#lstStatus").val();
            window.open(url, "_blank");
        }

    </script>
     <style type="text/css"> 
 
            body{ padding:5px; margin:0; padding-bottom:15px;}
            #layout1{  width:100%;margin:0; padding:0;  }  
            .l-page-top{ height:80px; background:#f8f8f8; margin-bottom:3px;}
            h4{ margin:20px;}
  </style>
  
</head>
<body style="padding:10px">

     <div id="layout1">
            <div position="left" title=""  style="overflow: auto;">
             <div id="treePanel" >
              <ul id="Orgtree"></ul>
              </div>
            </div><!-- end-->
            <div  position="center" title="">
             <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="70">职务名称:</td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="80"><input id="roleName" type="text" /></td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="70">职务状态:</td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="80">
                        <select id="lstStatus">
                            <option value="-1" title="全部" selected="selected">全部</option>
                            <option value="1">启用</option>
                            <option value="0">停用</option>
                        </select>
                    </td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="80"><a  class="l-button" style="width:60px; float:left; margin-left:10px;" id="search_button"   onclick="Search()">查寻</a></td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="80"><a  class="l-button" style="width:60px; float:left; margin-left:10px;" id="addrole"  onclick="AddRole()">新建职务</a></td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;" width="80"><a  class="l-button" style="width:60px; float:left; margin-left:10px;"   onclick="FenRole()">职务分配</a></td>
                    <td style="background: #E5EDEF; padding-left:5px; padding-top: 3px;"><a  class="l-button" style="width:60px; float:left; margin-left:10px;"   onclick="ExportExecl()">导出</a></td>
                </tr>
             </table>
               <div id="maingrid"></div> 
            </div>
             

   </div> 
   <a id="ExdcleGo" href=""></a>
   <input type="hidden" id="Aid" value="-1" />
   <input type="hidden" id="Rid" value="-1" />
   <input type="hidden" id="hdAreaName" value="" />
   
 
</body>
</html>
